package com.ghline.caloncabe.model;

import com.ghline.caloncabe.GameView;

import android.graphics.Bitmap;
import android.graphics.Canvas;

public class MySprite {
	private int x = 0;
    private int y = 0;
    private GameView gameView;
    private Bitmap bmp;
    private int width;
    private int height;
    private boolean isTouched;
	
	public MySprite(GameView gameView, Bitmap bmp, int x, int y) {
		
		this.setGameView(gameView);
        this.bmp = bmp;
        this.width = bmp.getWidth();
        this.height = bmp.getHeight();
        this.x = x;
        this.y = y;
	}

	public void draw(Canvas canvas) {	
		canvas.drawBitmap(bmp, x, y, null);
	}
	
	public void handleActionDown(int eventX, int eventY) {
		if (eventX >= this.x && eventX <= this.x + this.width
				&& eventY >= this.y && eventY <= this.y + this.width) {
			setTouched(true);
		}
		else {
			setTouched(false);
		}
	}

	public int getWidth() {
		return width;
	}
	public int getHeight() {
		return height;
	}
	public int getX() {
		return x;
	}
	public int getY() {
		return y;
	}
	public Bitmap getBmp() {
		return bmp;
	}
	public void setBmp(Bitmap bmp) {
		this.bmp = bmp;
	}

	public boolean isTouched() {
		return isTouched;
	}

	public void setTouched(boolean isTouched) {
		this.isTouched = isTouched;
	}

	public GameView getGameView() {
		return gameView;
	}

	public void setGameView(GameView gameView) {
		this.gameView = gameView;
	}
}
